/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dogy;

import GUI.LoginForm;
import Interfaces.Loadable;
import functions.Dogy;
import functions.LogError;
import java.awt.Toolkit;
import javax.swing.UIManager;

/**
 *
 * @author JArik
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception
    {

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) 
        {
            LogError.reportSilentError(e);
        }
        try
        {
            Dogy.initLoading(2, "Проверка обновления", new Loadable(){
            @Override
            public Object load()
            {
                Dogy.checkOnlineUpdate(Dogy.UPDATE_URL);
                Dogy.retreiveSettings();
                return null;
            }
            public void done(Object done)
            {
                LoginForm loginFrame = new LoginForm();
                loginFrame.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - loginFrame.getWidth()) / 2,
                        (Toolkit.getDefaultToolkit().getScreenSize().height - loginFrame.getHeight()) / 2);

                loginFrame.setVisible(true);
            }
            @Override
            public Object cancel()
            {

                return null;
            }

            @Override
            public void progress(int p) {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        });
        }
        catch(Exception e)
        {
            LogError.reportSilentError(e);
        }

    }
}
